<!DOCTYPE html>
<html lang="en">

<head>
    <title></title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <block name="style">
        <link rel="stylesheet" href="__MYCSS__/main.min.css">
        <link rel="stylesheet" type="text/css" href="__STATIC__/uploadify/uploadify.css" />
    </block>
</head>
<extend name="Public/base" />
<block name="body">

    <body>
        <ol class="breadcrumb">
            <li><a href="#">商务管理</a></li>
            <li class="active">客户资源业务表</li>
        </ol>
        <div style="margin-bottom: 4px">
            <a class="btn btn-primary" role="button" data-toggle="collapse" href="#collapseExample" aria-expanded="true" aria-controls="collapseExample">查询</a>
            <button type="button" class="btn btn-default" data-toggle="modal" data-target="#addModal">添加</button>
            <div id="uploader" class="wu-example btn btn-primary">
                <div class="btns">
                    <div id="picker">Excel导入</div>
                </div>
            </div>
            <a class="btn btn-primary" href="{:U('csv_export',array('txt_name'=>$txt_name))}">csv导出</a>
            <div id="thelist" class="uploader-list">
            </div>
        </div>


        <div class="collapse" id="collapseExample">
            <div class="well">
                <form method="GET" action="{:U('lst')}">
                    <div class="row">
                        <div class="col-lg-2 col-sm-6">
                            <div class="form-group">
                                <label for="exampleInputName2">客户名称：</label>
                                <select class="form-control" name="khmc">
                                    <option value="">--请选择--</option>
                                    <volist name="khmc_arr" id="khmc">
                                        <option value="{$khmc}">{$khmc}</option>
                                    </volist>
                                 </select>
                            </div>
                        </div>

                        <div class="col-lg-2 col-sm-6">
                            <div class="form-group">
                                <label for="exampleInputName2">对应内部公司：</label>
                                <select class="form-control" name="dynbgs">
                                    <option value="">--请选择--</option>
                                     <volist name="dynbgs_arr" id="dynbgs">
                                        <option value="{$dynbgs}">{$dynbgs}</option>
                                    </volist>
                                </select>
                            </div>
                        </div>
                        <div class="col-lg-1 col-sm-3">
                            <div class="form-group">
                                <label for="year">所属年份：</label>
                                <select class="form-control father_select year_select" name="year">
                                    <option value="">--请选择--</option>
                                </select>
                            </div>
                        </div>
                        <div class="col-lg-1 col-sm-3">
                            <div class="form-group">
                                <label for="month">所属月份：</label>
                                <select class="form-control son_select month_select" name="month" disabled="disabled">
                                    <option value="">--请选择--</option>
                                </select>
                            </div>
                        </div>

                        <div class="col-lg-2 col-sm-3" style="margin-top: 25px;">
                            <button type="submit" class="btn btn-success">查询</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
        <div class="panel panel-default">
            <div class="panel-heading">客户资源表</div>
            <div class="surface_table">
                <div class="table-head">
                    <table class="table table-bordered">
                        <thead>
                            <tr class="table-h">
                                <th>所属时间</th>
                                <th>业务区域</th>
                                <th>业务板块</th>
                                <th>客户名称</th>
                                <th>对应内部公司</th>
                                <th>运营商类型</th>
                                <th>开票</th>
                                <th>开通日期</th>
                                <th>计费日期</th>
                                <th>结束日期</th>
                                <th>天数</th>
                                <th>个数</th>
                                <th>单价</th>
                                <th>金额</th>
                                <th>调整历史</th>
                                <th>总调整</th>
                                <th>调整后应收</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                    </table>
                </div>
                <div class="table-body">
                    <table class="table table-hover table-bordered">
                        <tbody>
                            <volist name="lsts" id="list">
                                <tr>
                                    <td>{$list.sssj}</td>
                                    <td>{$list.ywqy}</td>
                                    <td>{$list.ywbk}</td>
                                    <td>{$list.khmc}</td>
                                    <td>{$list.dynbgs}</td>
                                    <td>{$list.yyslx}</td>
                                    <td>{$list.kp}</td>
                                    <td>{$list.ktrq}</td>
                                    <td>{$list.jfrq}</td>
                                    <td>{$list.jsrq}</td>
                                    <td>{$list.ts_sum}</td>
                                    <td class="count_gs">{$list.gs}</td>
                                    <td>{$list.dj}</td>
                                    <td class="count_je">{$list.je}</td>
                                    <td><button type="button" data-val='{$list.tz_h}' class="btn btn-warning showtz_btn" data-toggle="modal"
                                            data-target="#showtzModal">查看</button></td>
                                    <td class="count_tz">{$list.tz}</td>
                                    <td class="count_ys">{$list.ys}</td>
                                    <td>
                                        <button type="button" data-id="{$list.id}" class="btn btn-warning update_btn" data-toggle="modal" data-target="#updateModal">修改</button>
                                        <a class="btn btn-danger delete_btn" href="{:U('del',array('id'=>$list['id']))}" role="button">删除</a>
                                    </td>
                                </tr>
                            </volist>
                            <tr>
                                <td colspan="11" style="text-align: center">总计</td>
                                <td id="count_gs" class="count"></td>
                                <td></td>
                                <td id="count_je" class="count"></td>
                                <td></td>
                                <td id="count_tz" class="count"></td>
                                <td id="count_ys" class="count"></td>
                                <td></td>
                            </tr>
                        </tbody>
                    </table>
                </div>

            </div>

        </div>
        <!--添加面板-->
        <div class="modal fade bs-example-modal-lg" id="addModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
            <div class="modal-dialog modal-lg" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="myModalLabel">增加财务表单</h4>
                    </div>
                    <div class="modal-body">
                        <form class="public_form khzyForm" action="{:U('add')}" method="post">
                            <div class="row">
                                <div class="col-lg-4 col-sm-4">
                                    <div class="form-group">
                                        <label for="addywqy">业务区域</label>
                                        <input type="text" class="form-control" id="addywqy" name="ywqy">
                                    </div>
                                </div>
                                <div class="col-lg-4 col-sm-4">
                                    <div class="form-group">
                                        <label for="addywbk">业务板块</label>
                                        <input type="text" class="form-control" id="addywbk" name="ywbk">
                                    </div>
                                </div>
                                <div class="col-lg-4 col-sm-4">
                                    <div class="form-group">
                                        <label for="addkhmc">客户名称</label>
                                        <input type="text" class="form-control" id="addkhmc" name="khmc">
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-lg-4 col-sm-4">
                                    <div class="form-group">
                                        <label for="adddynbgs">对应内部公司</label>
                                        <input type="text" class="form-control" id="adddynbgs" name="dynbgs">
                                    </div>
                                </div>
                                <div class="col-lg-4 col-sm-4">
                                    <div class="form-group">
                                        <label for="addyyslx">运营商类型</label>
                                        <input type="text" class="form-control" id="addyyslx" name="yyslx">
                                    </div>
                                </div>
                                <div class="col-lg-4 col-sm-4">
                                    <div class="form-group">
                                        <label for="addktrq">开通日期</label>
                                        <input type="text" class="form-control form_date" value="" id="addktrq" name="ktrq" data-date-format="yyyy-mm-dd" readonly>
                                    </div>
                                </div>

                            </div>
                            <div class="row">
                                <div class="col-lg-4 col-sm-4">
                                    <div class="form-group">
                                        <label for="addjfrq">计费日期</label>
                                        <input type="text" class="form-control form_date" value="" id="addjfrq" name="jfrq" data-date-format="yyyy-mm-dd" readonly>
                                    </div>
                                </div>
                                <div class="col-lg-4 col-sm-4">
                                    <div class="form-group">
                                        <label for="addjsrq">结束日期</label>
                                        <input type="text" class="form-control form_date" value="" id="addjsrq" name="jsrq" data-date-format="yyyy-mm-dd" readonly>
                                    </div>
                                </div>
                                <div class="col-lg-4 col-sm-4">
                                    <div class="form-group">
                                        <label for="addsssj">所属日期</label>
                                        <input type="text" class="form-control form_date" value="" id="addsssj" name="sssj" data-date-format="yyyy-mm-dd" readonly>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-lg-4 col-sm-4">
                                    <div class="form-group">
                                        <label for="addgs">个数</label>
                                        <input type="text" class="form-control" id="addgs" name="gs">
                                    </div>
                                </div>
                                <div class="col-lg-4 col-sm-4">
                                    <div class="form-group">
                                        <label for="adddj">单价</label>
                                        <input type="text" class="form-control" id="adddj" name="dj">
                                    </div>
                                </div>
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="kp">是否开票：</label>
                                        <div>
                                            <label class="checkbox-inline">
                                                <input type="radio" name="kp" id="kp" value="是" checked> 是
                                            </label>
                                            <label class="checkbox-inline">
                                                <input type="radio" name="kp" id="kp" value="否" > 否
                                            </label>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-lg-4 col-sm-4">
                                    <div class="form-group">
                                        <label for="additz">单次调整</label>
                                        <input type="text" class="form-control" id="additz" name="itz">
                                    </div>
                                </div>
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                                <button type="submit" class="btn btn-primary">保存表单</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
        <!--修改面板-->
        <div class="modal fade bs-example-modal-lg" id="updateModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
            <div class="modal-dialog modal-lg" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="myModalLabel">修改财务表单</h4>
                    </div>
                    <div class="modal-body">
                        <form class="public_form khzyForm update_form" action="{:U('edit')}" method="post">
                            <div class="row">
                                <div class="col-lg-4 col-sm-4">
                                    <div class="form-group">
                                        <label for="updateywqy">业务区域</label>
                                        <input type="text" class="form-control" id="updateywqy" name="ywqy">
                                    </div>
                                </div>
                                <div class="col-lg-4 col-sm-4">
                                    <div class="form-group">
                                        <label for="updateywbk">业务板块</label>
                                        <input type="text" class="form-control" id="updateywbk" name="ywbk">
                                    </div>
                                </div>
                                <div class="col-lg-4 col-sm-4">
                                    <div class="form-group">
                                        <label for="updatekhmc">客户名称</label>
                                        <input type="text" class="form-control" id="updatekhmc" name="khmc">
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-lg-4 col-sm-4">
                                    <div class="form-group">
                                        <label for="updatedynbgs">对应内部公司</label>
                                        <input type="text" class="form-control" id="updatedynbgs" name="dynbgs">
                                    </div>
                                </div>
                                <div class="col-lg-4 col-sm-4">
                                    <div class="form-group">
                                        <label for="updateyyslx">运营商类型</label>
                                        <input type="text" class="form-control" id="updateyyslx" name="yyslx">
                                    </div>
                                </div>
                                <div class="col-lg-4 col-sm-4">
                                    <div class="form-group">
                                        <label for="updatektrq">开通日期</label>
                                        <input type="text" class="form-control form_date" value="" id="updatektrq" name="ktrq" data-date-format="yyyy-mm-dd" readonly>
                                    </div>
                                </div>

                            </div>
                            <div class="row">
                                <div class="col-lg-4 col-sm-4">
                                    <div class="form-group">
                                        <label for="updatejfrq">计费日期</label>
                                        <input type="text" class="form-control form_date" value="" id="updatejfrq" name="jfrq" data-date-format="yyyy-mm-dd" readonly>
                                    </div>
                                </div>
                                <div class="col-lg-4 col-sm-4">
                                    <div class="form-group">
                                        <label for="updatejsrq">结束日期</label>
                                        <input type="text" class="form-control form_date" value="" id="updatejsrq" name="jsrq" data-date-format="yyyy-mm-dd" readonly>
                                    </div>
                                </div>
                                <div class="col-lg-4 col-sm-4">
                                    <div class="form-group">
                                        <label for="updatesssj">所属日期</label>
                                        <input type="text" class="form-control form_date" value="" id="updatesssj" name="sssj" data-date-format="yyyy-mm-dd" readonly>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-lg-4 col-sm-4">
                                    <div class="form-group">
                                        <label for="updategs">个数</label>
                                        <input type="text" class="form-control" id="updategs" name="gs">
                                    </div>
                                </div>
                                <div class="col-lg-4 col-sm-4">
                                    <div class="form-group">
                                        <label for="updatedj">单价</label>
                                        <input type="text" class="form-control" id="updatedj" name="dj">
                                    </div>
                                </div>
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="kp">是否开票：</label>
                                        <div>
                                            <label class="checkbox-inline">
                                                <input type="radio" name="kp" class="form-control" id="kp" value="是" checked> 是
                                            </label>
                                            <label class="checkbox-inline">
                                                <input type="radio" name="kp" class="form-control" id="kp" value="否" > 否
                                            </label>
                                        </div>
                                    </div>
                                </div>

                            </div>
                            <div class="row">
                                <div class="col-lg-4 col-sm-4">
                                    <div class="form-group">
                                        <label for="updateitz">单次调整</label>
                                        <input type="text" class="form-control" id="updateitz" name="itz">
                                    </div>
                                </div>
                            </div>
                            <input type="hidden" id="update_id" name="id">
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                                <button type="submit" class="btn btn-primary">保存表单</button>
                            </div>
                        </form>
                    </div>

                </div>

            </div>
        </div>
        <!--查看调整历史-->
        <div class="modal fade " id="showtzModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="myModalLabel">查看调整历史</h4>
                    </div>
                    <div class="modal-body">
                        <table class="table table-striped" id="tztable">
                            <thead>
                                <tr>
                                    <th>修改日期</th>
                                    <th>调整数值</th>
                                </tr>
                            </thead>
                            <tbody>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
        <script src="__MYJS__/main.min.js"></script>
        <script src="__MYJS__/table.js"></script>
        <script src="__MYJS__/main.js"></script>
        <script src="__MYJS__/validator.js"></script>
        <script type="text/javascript" src="__MYJS__/upload.js"></script>
        <script>
            $(function () {
                // 修改按钮事件
                $("table").on("click", ".update_btn", function (e) {
                    e.stopPropagation();
                    var id = $(this).attr("data-id");
                    $.ajax({
                        url: "{:U('edit')}",
                        type: 'GET', //GET
                        data: {
                            id: id
                        },
                        success: function (data) {
                            $(".update_form .form-control").each(function (index, val) {
                                var self = this;
                                for (x in data) {
                                    if (x == "kp" && $(self).attr("name") == x) {
                                        $(":radio[name='" + x + "'][value='" + data[
                                                x] +
                                            "']").prop("checked", "checked");
                                    } else if ($(self).attr("name") == x) {
                                        $(self).val(data[x]);
                                    }
                                }
                            });
                            // 重新更新日期选择器
                            $(".update_form .form_date").each(function (index, val) {
                                if ($(this).val() != "") {
                                    $(this).val(moment($(this).val(),
                                        "YYYYMMDD").format(
                                        "YYYY-MM-DD"))
                                }
                            })
                            $(".update_form .form_date").datetimepicker('update');
                        }
                    })
                    $("#update_id").val(id);
                    $('#updateModal').modal()
                })
                $("table").on("click", ".showtz_btn", function (e) {
                    $("#tztable").find("tbody").empty()
                    var value = $(this).attr("data-val");
                    if (value) {
                        var tzobj = eval('(' + value + ')');
                        for (i in tzobj) {
                            $("#tztable").find("tbody").append("<tr>" +
                                "<td>" + i + "</td>" +
                                "<td>" + tzobj[i] + "</td>" +
                                "</tr>")
                        }
                    }
                })
                var zdytable = new window.zdytable()
                window.upload("{:U('import')}")
            })
        </script>

    </body>
</block>

</html>